package com.basics.framework.security.service;/*
package com.basics.framework.security.service;


import com.basics.user.utils.ServletUtils;
import com.basics.user.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.Iterator;
import java.util.Set;

@Service("ss")
public class PermissionService {
    private static final String ALL_PERMISSION = "*:*:*";
    private static final String SUPER_ADMIN = "1234123";
    private static final String ROLE_DELIMETER = ",";
    private static final String PERMISSION_DELIMETER = ",";
    @Autowired
    private TokenService tokenService;

    public PermissionService() {
    }

    public boolean hasPermi(String permission) {
        if (StringUtils.isEmpty(permission)) {
            return false;
        } else {
            LoginUser loginUser = this.tokenService.getLoginUser(ServletUtils.getRequest());
            return !StringUtils.isNull(loginUser) && !CollectionUtils.isEmpty(loginUser.getPermissions()) ? this.hasPermissions(loginUser.getPermissions(), permission) : false;
        }
    }

    public boolean lacksPermi(String permission) {
        return !this.hasPermi(permission);
    }

    public boolean hasAnyPermi(String permissions) {
        if (StringUtils.isEmpty(permissions)) {
            return false;
        } else {
            LoginUser loginUser = this.tokenService.getLoginUser(ServletUtils.getRequest());
            if (!StringUtils.isNull(loginUser) && !CollectionUtils.isEmpty(loginUser.getPermissions())) {
                Set<String> authorities = loginUser.getPermissions();
                String[] var4 = permissions.split(",");
                int var5 = var4.length;

                for(int var6 = 0; var6 < var5; ++var6) {
                    String permission = var4[var6];
                    if (permission != null && this.hasPermissions(authorities, permission)) {
                        return true;
                    }
                }

                return false;
            } else {
                return false;
            }
        }
    }

    public boolean hasRole(String role) {
        if (StringUtils.isEmpty(role)) {
            return false;
        } else {
            LoginUser loginUser = this.tokenService.getLoginUser(ServletUtils.getRequest());
            if (!StringUtils.isNull(loginUser) && !CollectionUtils.isEmpty(loginUser.getUser().getRoles())) {
                Iterator var3 = loginUser.getUser().getRoles().iterator();

                String roleId;
                do {
                    if (!var3.hasNext()) {
                        return false;
                    }

                    AppRole AppRole = (AppRole)var3.next();
                    roleId = AppRole.getRoleId();
                } while(!"1234123".contains(roleId) && !roleId.contains(StringUtils.trim(role)));

                return true;
            } else {
                return false;
            }
        }
    }

    public boolean lacksRole(String role) {
        return !this.hasRole(role);
    }

    public boolean hasAnyRoles(String roles) {
        if (StringUtils.isEmpty(roles)) {
            return false;
        } else {
            LoginUser loginUser = this.tokenService.getLoginUser(ServletUtils.getRequest());
            if (!StringUtils.isNull(loginUser) && !CollectionUtils.isEmpty(loginUser.getUser().getRoles())) {
                String[] var3 = roles.split(",");
                int var4 = var3.length;

                for(int var5 = 0; var5 < var4; ++var5) {
                    String role = var3[var5];
                    if (this.hasRole(role)) {
                        return true;
                    }
                }

                return false;
            } else {
                return false;
            }
        }
    }

    private boolean hasPermissions(Set<String> permissions, String permission) {
        return permissions.contains("*:*:*") || permissions.contains(StringUtils.trim(permission));
    }
}*/
